import {findAll, findOrderGoods, GetdataDictionary, returnGood} from "@/api/b2c/order";
import pickerOptions from "@/utils/date";

export default {
    name: "index",
    data() {
        return {
            dialogFormVisible: false,
            payTypeList: [],
            orderActionlist: [],
            orderTypeList: [],
            orderStatusList: [],
            businessTypeList: [],
            orderList: [],
            orderProductList: [],
            goodList:[],
            rejectReasonList:[],
            formData:{},
            total: 0,
            pickerOptions: pickerOptions,
            searchParams: {
                currentPage: 1,
                pageSize: 8,
                id: ``,
                orderType: ``,
                paymentMethodId: ``,
                orderAction: ``,
                businessType: ``,
                orderStatus:``,
                deliveryArea:``,
                rejectReason:``,
                productName:``,
                receiverName:``
            },
            table: {}

        }
    },
    methods: {
        findOrderList() {
            findAll().then(response => {
                this.orderList = response;
                console.log(this.orderList)
            })
        },
        //分页查询
        async pageFind() {
            console.log(this.searchParams);
            let response = await returnGood(this.searchParams)
            this.total = response.total;
            this.orderList = response.data;
        },
        //页面变化
        currentPageChange(currentIndex) {
            // console.log(currentIndex);
            this.searchParams.currentPage = currentIndex;
            this.pageFind()
        },
        //选择时间
        chooseTime() {
            this.searchParams.startTime = this.pickerOptions.startDate[0];
            this.searchParams.endTime = this.pickerOptions.startDate[1];
        },
        //重置
        resetForm() {
            this.searchParams = {
                currentPage: 1,
                pageSize: 8,
            }
            this.pickerOptions.startDate = '';
            this.pageFind();
        },
        //选中数据
        handleSelectionChange(val) {
            this.multipleSelection = val;
            console.log(val);
        },

        async querydic() {

            //1.订单动作 2 订单状态 3 业务类型 4 配送方式  5 支付方式  6订单分类订单类型 7 退货原因 ',
            let result = await GetdataDictionary();
            console.log(result)
            this.rejectReasonList = result[7]
        },
        async findOrderById(row) {
            console.log(row);
            console.log(row.id)

            this.formData = await row

            this.goodList = await findOrderGoods(row.id)
        },
        // async findGood(row){
        //  console.log(row)
        // }
        //改变表格订单状态的颜色

    },
    created() {
        this.pageFind()
        this.querydic()
    }
}